package com.example.sharpshopdemo.controller;

import com.example.sharpshopdemo.entity.Result;
import com.example.sharpshopdemo.entity.Role;
import com.example.sharpshopdemo.service.RoleService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;



@RestController
@RequestMapping("/role")
@CrossOrigin
public class RoleController {

    @Autowired
    private RoleService service;

    @GetMapping("/list")
    public Result list(){
        return service.getAll();
    }

    @PostMapping("/add")
    @Operation(summary = "添加用户")
    public Role insertData(Role role){
        return new Role();
    }

    @PostMapping("/update")
    @Operation(summary = "更新数据")
    public Role updateDate(Role role){
        return new Role();
    }

    @PostMapping("/delete")
    @Operation(summary = "删除数据")
    public Role deleteDate(Role role){
        return new Role();
    }
    @Autowired
    private RoleService roleService;

    // 模糊查询端点
    @GetMapping("/roles/name-like")
    public Result<List<Role>> findRolesByNameLike(@RequestParam String keyword) {
        return roleService.findRolesByNameLike(keyword);
    }

//    @PostMapping("/selectById")
//    public ResponseEntity<Result> selectData(Integer dictId,String display,Integer superId){
//
//    Result result =service.getById(dictId,display,superId);
//    return ResponseEntity.ok(result);
//    }





}
